<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    use HasFactory;
    protected $guarded=[];
    protected $deleteTime = 'deleted_at';

    public function nodes()
    {
        //第一个参数代表你要关联的模型名
        //第二个参数是关系表（中间表）表名
        //第三个参数是本模型在中间表的外键id
        //第四个参数就是关联表在中间表的外键id
        return $this->belongsToMany(Node::class,'role_nodes','role_id','node_id');
    }
}
